﻿using System;
using System.Web.Compilation;

namespace MvcFckEditor.Components
{
    public abstract class FckProvider
    {
        private static FckProvider objProvider;

        public static FckProvider Instance()
        {
            return objProvider;
        }

        static FckProvider()
        {
            string typeName = System.Configuration.ConfigurationManager.AppSettings["FckProvider"];
            objProvider = (FckProvider)Activator.CreateInstance(CreateType(typeName));
        }

        public static Type CreateType(string TypeName)
        {
            Type objObject = null;
            try
            {
                objObject = BuildManager.GetType(TypeName, true, true);
            }
            catch
            {
                objObject = BuildManager.GetType("MvcFckEditor.Components.DefaultFckProvider, MvcFckEditor", true, true);
            }
            return objObject;
        }

        public abstract string GetUserFilesPath();
    }
}
